
//登录成功以及出现退出登录
var name=document.getElementsByClassName('userName')[0];
var login=document.getElementsByClassName('login')[0];
var persons=document.getElementsByClassName('persons')[0];
var out=document.getElementsByClassName('out')[0];
var hideLogOut = document.getElementsByClassName('hideLogOut')[0];
var hideLogOutContent = document.getElementsByClassName('hideLogOutContent')[0];
var logOutNoBtn=document.getElementsByClassName('logOutNoBtn')[0];
var logOutYesBtn=document.getElementsByClassName('logOutYesBtn')[0];
if(localStorage.getItem('userHao')!=null || localStorage.getItem('sign')==1){
    login.style.display='none';
    persons.style.display='block';
}
console.log(localStorage.getItem('userHao'))
console.log(localStorage.getItem('password'))
out.onclick=function(){
    setTimeout(function(){
        hideLogOut.style.display = 'block';
        hideLogOutContent.style.opacity = '1';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + 400 + "px)";
    },1)
    logOutNoBtn.onclick = function(){
        hideLogOutContent.style.opacity = '0';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + -400 + "px)";
        hideLogOut.style.display = 'none';
    }
//点击确认会退出登录
    logOutYesBtn.onclick = function(){
        hideLogOutContent.style.opacity = '0';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + -400 + "px)";
        hideLogOut.style.display = 'none';
        persons.style.display='none';
        login.style.display='block';
        localStorage.removeItem('userHao');
        localStorage.removeItem('password');
        localStorage.removeItem('sign');
        window.location.href="http://localhost:8080/future/out";
    }


}




// 轮播图
var items=document.getElementsByClassName('item');
var points=document.getElementsByClassName('point');
var goPreBtn=document.getElementById('goPre');
var goNextBtn=document.getElementById('goNext');

var index=0;//index表示第几张图片在展示，第index张图片有active这个类名

var time=0;
var clearActive=function(){
    for(var i=0;i<items.length;i++){
        items[i].className='item';
    }
    for(var i=0;i<points.length;i++){
        points[i].className='point';
    }
}
var goIndex=function(){
    clearActive();
//				console.log(index);
    points[index].className='point active';
    items[index].className='item active';
}
var goNext=function(){
    if(index<4){
        index++;
    }else{
        index=0;
    }
    goIndex();
}
var goPre=function(){
    if(index==0){
        index=4;
    }else{
        index--;
    }
    goIndex();
}
goNextBtn.addEventListener('click',function(){
    goNext();
})
goPreBtn.addEventListener('click',function(){
    goPre();
})
for(var i=0;i<points.length;i++){
    points[i].addEventListener('click',function(){
        var pointIndex=this.getAttribute('data-index');
        index=pointIndex;
        
        goIndex();
        time=0;
    })
}
setInterval(function(){
    time++;
    if(time==20){
        goNext();
        time=0;
    }
},100)
// 当鼠标放到图片上的时候会有播放的开关
// .$(document).ready(function(){
//     $(".bigImg").mouseover(function(){
//         $(".mask").show();
//     });
//     $(".bigImg").mouseout(function(){
//         $(".mask").hide();
//     });
// });
// 侧边栏
var side=document.getElementsByClassName("side")[0];
document.onscroll=function(){
    var top=document.documentElement.scrollTop;
	if(top>800){
		side.style.opacity="1";
	}else {
		side.style.opacity="0";
	}
}
function toTop(){
    var backTopTimer=setInterval(function(){
    var topH=document.documentElement.scrollTop||document.body.scrollTop;
    var backTopSpeed=Math.floor(-topH/8);
    if(topH>0){
        document.documentElement.scrollTop=document.body.scrollTop=topH+backTopSpeed;	
    }else {
        clearInterval(backTopTimer);
        
    }
},10);
}
// 推荐歌单的变换页面
var refers=document.getElementsByClassName('refer');
var mvs=document.getElementsByClassName('mv');

var noActive=function(){
    for(let i=0;i<mvs.length;i++){
        mvs[i].className='mv'
    }
    for(let i=0;i<refers.length;i++){
        refers[i].className='refer';
    }
}
var gotoIndex=function(e){
    console.log(e)
    noActive();
    mvs[e].className='mv active';
    refers[e].className='refer active';
}
for(let i=0;i<refers.length;i++){
    refers[i].addEventListener('click',function(){
        console.log(i);
        gotoIndex(i);
    })
}
// 判断是否登录
var hideVipLoad=document.getElementsByClassName('hideVipLoad')[0];
var hideVipLoadForm=document.getElementsByClassName('hideVipLoadForm')[0];
var vipBtn=document.getElementsByClassName('vipBtn')[0];
var loadBtn=document.getElementsByClassName('loadBtn')[0];
var closeVip=document.getElementsByClassName('closeVip')[0];
var myMusic=document.getElementsByClassName('myMusic')[0];
// vip的界面
vipBtn.onclick=function(){
    if(localStorage.getItem('userHao')!=null|| localStorage.getItem('sign')==1){
        window.location.href='http://localhost:8080/future/toVIPpaper';
    }else{
        hideVipLoad.style.display='block';
        hideVipLoadForm.style.opacity='1';
        closeVip.onclick=function(){
            hideVipLoad.style.display='none';
            hideVipLoadForm.style.opacity='0';
        }
        loadBtn.onclick=function(){
            window.location.href='http://localhost:8080/future/loginpage';
        }
    }

}
// 我的音乐的界面
myMusic.onclick=function(){
    if(localStorage.getItem('userHao')!=null|| localStorage.getItem('sign')==1){
        window.location.href='http://localhost:8080/future/toMyMusicpaper';
    }else{
        hideVipLoad.style.display='block';
        hideVipLoadForm.style.opacity='1';
        closeVip.onclick=function(){
            hideVipLoad.style.display='none';
            hideVipLoadForm.style.opacity='0';
        }
        loadBtn.onclick=function(){
            window.location.href='http://localhost:8080/future/loginpage';
        }
    }
}

// // 判断是否登录 end
// 点击反馈会出现弹框
var feed=document.getElementsByClassName('feed')[0];
var hideBack=document.getElementsByClassName('hideBack')[0];
var hideBackForm=document.getElementsByClassName('hideBackForm')[0];
var closeBack=document.getElementsByClassName('closeBack')[0];
closeBack.onclick = closeFeedback;
feed.onclick=function(){
    hideBack.style.display='block';
    hideBackForm.style.opacity='1';
}
function closeFeedback(){
    hideBack.style.display='none';
    hideBackForm.style.opacity='0';
}


// logOutYesBtn.onclick=function(){
//     $.ajax({
//         url:"http://localhost:8080/future/out",
//         method:'POST',
//         success: function (data) {
//         },
//         error: function (err) {//请求失败，执行的回调函数
//         }
//     })
// }